import mixincommon from "@/mixins/common";

import isSelectApprover from "@/mixins/isSelectApprover";

export default {
    mixins:[mixincommon,isSelectApprover],
    data() {
        return {
          title:"",
          visible: false,
          detailVisible: false,
          currRow: {},
          showActiveBtn: false,
        };
    },
    mounted() {
        this.$nextTick(function () {
            this.openDialogById()
        })
    },
    computed:{
    },
    methods: {
      openDialogById(){
        this.$store.dispatch("common/getDetailInfoById").then(res=>{
          res.id&&this.showDialog(res)
        })
      },
      showDialog(row, type) {
        if(row.id){
          this.api.getDetailInfoById(row.id).then(res=>{
            this.currRow  = res.data
            if(type=="edit" || (type==undefined && this.currRow.is_edit)){
              this.visible = true
              this.title="编辑-"+this.currRow.title
            } else if (type == "handle" || type==undefined) {
              this.showActiveBtn = true
              this.detailVisible = true
              this.title="查看-"+this.currRow.title
            } else if (type == 'view') {
              this.showActiveBtn = false
              this.detailVisible = true
              this.title="查看-"+this.currRow.title
            }
          })
        }else{
          this.currRow  =row
          this.visible = true;
          this.title = "新建" + this.$route.meta.title
        }
      },
    }
};
